#include "StdAfx.h"
#include "Plane.h"

VAMPIRE_NAMESPACE_BEGIN

Plane Plane::operator+() const
{
	return *this;
}

Plane Plane::operator-() const
{
	return Plane(-mData);
}

Plane Plane::operator*( const Real& rhs ) const
{
	return Plane(mData * rhs);
}

Plane Plane::operator/( const Real& rhs ) const
{
	return Plane(mData / rhs);
}

Plane& Plane::operator*=( const Real& rhs )
{
	mData *= rhs;
	return *this;
}

Plane& Plane::operator/=( const Real& rhs )
{
	mData /= rhs;
	return *this;
}

BOOL Plane::operator==( const Plane& rhs ) const
{
	return mData == rhs.mData ? TRUE : FALSE;
}

BOOL Plane::operator!=( const Plane& rhs ) const
{
	return mData == rhs.mData ? FALSE : TRUE;
}

Real Plane::dotCoord( const Vector3& coord )
{
	return D3DXPlaneDotCoord(&mData, &(coord.mData));
}

Vampire::Real Plane::dotNormal( Vector3 normal )
{
	normal.normalise();
	return D3DXPlaneDotNormal(&mData, &(normal.mData));
}

void Plane::fromPointNormal( const Vector3& normal, const Vector3& point )
{
	D3DXPlaneFromPointNormal(&mData, &(point.mData), &(normal.mData));
}

void Plane::fromThreePoints( const Vector3& v1, const Vector3& v2, const Vector3& v3 )
{
	D3DXPlaneFromPoints(&mData, &(v1.mData), &(v2.mData), &(v3.mData));
}

void Plane::normalize()
{
	D3DXPlaneNormalize(&mData, &mData);
}

void Plane::scale( const Real& s )
{
	D3DXPlaneScale(&mData, &mData, s);
}

void Plane::transform( const Matrix44& matrix )
{
	D3DXPlaneTransform(&mData, &mData, &(matrix.mData));
}




VAMPIRE_NAMESPACE_END